function hashFunc(key: string, max:number):number{ 
    let hashCode = 0;
    const length = key.length;
    for (let i = 0; i < length; i++) {
        hashCode = 31 * hashCode + key.charCodeAt(i);
        console.log(hashCode);
    }
    // 计算出索引值
    const index = hashCode % max;

    return index
}


console.log(hashFunc('abc',7));
console.log(hashFunc('cba',7));
console.log(hashFunc('nba',7));
console.log(hashFunc('mba',7));
console.log(hashFunc('tba',7));
